# -*- coding: utf-8 -*-
#类和实例

import io
import sys
import types
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')

class Student(object):
	age = 0
	def __init__(self,name,score):
		self.__name = name
		self.__score = score
		self.x = 9
	def print_score(self):
		print('%s: %s' % (self.__name, self.__score))
	def get_grade(self):
		if self.__score >= 90:
			return 'A'
		elif self.__score >= 60:
			return 'B'
		else:
			return 'C'
	def getName(self):
		return self.__name

bart = Student('bon',10)
bart.print_score()
print(bart.get_grade())
print(bart.getName())


class Animal(object):
	def run(self):
		print('Animal is running...')
class Dog(Animal):
	def run(self):
		print('Dog is running...')
class Cat(Animal):
	def run(self):
		print('Cat is running...')

def run_twice(animal):
	animal.run()

dog = Dog()
dog.run()

cat = Cat()
cat.run()

run_twice(Animal())
run_twice(Dog())

print(type('str'))
print(type(123))

print(type(run_twice)==types.FunctionType)
print(type(lambda x: x)==types.LambdaType)
print(isinstance(dog,Dog))
print(dir(Dog))
print(hasattr(bart,'x'))
print(getattr(bart,'x'))

#实例属性 测试
s = Student('a','b')
print(s.age)
print(Student.age)

s.age = 1
print(s.age)
print(Student.age)

del s.age
print(s.age)
print(Student.age)